import React, { Component } from 'react'
import classNames from 'classnames'
import PropTypes from 'prop-types'

export default class TodoMain extends Component {
  static propTypes = {
    list: PropTypes.array,
  }
  render() {
    const { list = [] } = this.props
    return (
      <section className='main'>
        <input id='toggle-all' className='toggle-all' type='checkbox' />
        <label htmlFor='toggle-all'>Mark all as complete</label>
        <ul className='todo-list'>
          {/* 并渲染 */}
          {list.map((item) => (
            <li
              key={item.id}
              className={classNames({
                completed: item.done,
              })}
            >
              <div className='view'>
                <input
                  className='toggle'
                  type='checkbox'
                  checked={item.done}
                  onChange={() => {}}
                />
                <label>{item.name}</label>
                <button className='destroy'></button>
              </div>
              {/* <input className='edit' value='Create a TodoMVC template' /> */}
            </li>
          ))}
        </ul>
      </section>
    )
  }
}
